/*
 * RegularizedL2Comparator.cpp
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */


#include "../../../include/core/comparator/TractionTimesAreaRegularizedL2Comparator.h"
#include <vector>

TractionTimesAreaRegularizedL2Comparator::TractionTimesAreaRegularizedL2Comparator(AbstractDataContainer * DATA, double REGPARAMETER) : L2Comparator(DATA)
{
	reg_param = REGPARAMETER;
}

double TractionTimesAreaRegularizedL2Comparator::getRegularizationValue(SubstrateModel * substrate_model)
{
	double reg_value = 0;
	vector<ForceTransmission*> force_transmissions = substrate_model->get_force_transmissions();
	for(unsigned int i=0;i<force_transmissions.size();i++)
	{
		double area = force_transmissions[i]->get_shape()->get_area();
		double force_mag = force_transmissions[i]->get_force_magnitude();
		reg_value+=force_mag*force_mag/area;
	}
	return reg_value;
}
